import Mock from 'mockjs';

const loginUser = {
  userId: Mock.Random.guid().replace(/-/g,''),
  //password: 123456,
  //name: '金秀贤',
  phone: 13711112222
};

Mock.mock(/loginOut/,function(options) {
  let status = 0; // Mock.Random.boolean()? 0 : 500;
  return Mock.mock({
    code: status,
    msg: status == 0 ? '成功退出' : '后端返回的错误提示的信息！',
  });
})

Mock.mock(/login/,function(options) {
  console.log('login的axios传值为：',JSON.parse(options.body))//数据请求的传值
  let {phone, code} = JSON.parse(options.body)
  let status = phone == loginUser.phone? 0 : 500;
  return Mock.mock({
    msg: status == 0 ? '登录成功' : '后端返回的错误提示的信息！',
    code: status,
    data: {
      token: '@string(128)',
      phone: loginUser.phone
    }
  });
})

Mock.mock(/sendCheckCode/,function(options) {
  console.log('sendCheckCode的axios传值为：',JSON.parse(options.body))//数据请求的传值
  let status = 0; // Mock.Random.boolean()? 0 : 500;
  return Mock.mock({
    code: status,
    msg: status == 0 ? '验证码发送成功' : '后端返回的错误提示的信息！',
  });
})

Mock.mock(/changePhone/,function(options) {
  console.log('changePhone的axios传值为：',JSON.parse(options.body))//数据请求的传值
  let status = 0; // Mock.Random.boolean()? 0 : 500;
  return Mock.mock({
    code: status,
    msg: status == 0 ? '手机号修改成功' : '后端返回的错误提示的信息！'
  });
})